/**
 * Authors:
 * Vladimír Matěna
 * Jan Skalický
 */
package inireader;

/**
 * Exception for incorrect type casting.
 */
public class ElementTypeCastException extends RuntimeException
{
	/**
	 * Constructs a new ElementType cast exception
	 * with the specified detail message.
	 * @param description the detail message of exception
	 */
	public ElementTypeCastException(String description)
	{
		super(description);
	}

	/**
	 * Constructs a new ElementType cast exception
	 * with message constructed from types.
	 * @param fromType type from which cast
	 * @param toType type to which cast
	 */
	public ElementTypeCastException(ElementType fromType, ElementType toType)
	{
		super(String.format("Unpermitted type cast from %s to %s.", fromType.toString(), toType.toString()));
	}

	/**
	 * Constructs a new ElementType cast exception
	 * with message constructed from types + specified detail description.
	 * @param description detail description of exception
	 * @param fromType type from which cast
	 * @param toType type to which cast
	 */
	public ElementTypeCastException(String description, ElementType fromType, ElementType toType)
	{
		super(String.format("%s Unpermitted type cast from %s to %s.", description, fromType.toString(), toType.toString()));
	}
}
